<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script>
        $(function(){
            $("#styleCategoryCd,#styleFitCd,#styleSizeGroupCd,#styleSizeCd").select2();
        });

        //重置
        function clean(){
            $("#searchForm")[0].reset();
            $('#styleCategoryCd').val('');
            $("#styleCategoryCd").select2();
            $('#styleFitCd').val('');
            $("#styleFitCd").select2();
            $('#styleSizeGroupCd').val('');
            $("#styleSizeGroupCd").select2();
            $('#styleSizeCd').val('');
            $("#styleSizeCd").select2();
            $("#searchForm").submit();
        }

        //尺码组联动
        function subStyleSize(t,id){
            var code=$(t).find("option:selected").attr("data-value");
            var param={"code":code};
            $.post("${ctx}/fabric/consumption/styleSize",param,function(result){
                var html="<option value=''><spring:message code='size_pleaseChoosed'/></option>";
                $.each(result,function(i,e){
                    html+="<option value='"+e.itemCode+"-"+e.itemValue+"'>"+e.itemName+"</option>";
                });
                $("#"+id).html(html);
                $("#"+id).select2();
            },'json');
        }
    </script>
</head>
<body>
<form  id="searchForm" action="${ctx}/fabric/consumption/list" method="post">
    <c:set value="<%=ResourcesUtil.getConfig(\"size_styleCategory\")%>" var="styleCategory" />
    <c:set value="<%=ResourcesUtil.getConfig(\"size_styleFitCd\")%>" var="styleFit" />
    <c:set value="<%=ResourcesUtil.getConfig(\"size_styleSizeGroupCd\")%>" var="sizeGroup" />
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <div class="listSearchBox clearfix">
        <div class="searchLeft clearfix">
            <div class="searchSm clearfix">
                <!-- 款式类别 -->
                <p class="searchTxt"><spring:message code="size_styleCategory"/></p>
                <div class="searchInp">
                    <select style="width:100px" id="styleCategoryCd" name="styleCategoryCd"  >
                        <option value=""><spring:message code="size_pleaseChoosed"/></option>
                        <c:forEach items="${fns:getDictList(styleCategory)}"   var="category">
                            <option  <c:if test="${fn:split(consumption.styleCategoryCd,'-')[1] eq category.itemValue}">selected="selected"</c:if> value="${category.itemCode}-${category.itemValue}" >
                                    ${category.itemName}
                            </option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="searchSm clearfix">
                <!-- 版型 -->
                <p class="searchTxt"><spring:message code="size_styleFit"/></p>
                <div class="searchInp">
                    <select style="width:100px" id="styleFitCd" name="fitCd"  >
                        <option value=""><spring:message code="size_pleaseChoosed"/></option>
                        <c:forEach items="${fns:getDictList(styleFit)}"   var="fit">
                            <option  <c:if test="${fn:split(consumption.fitCd,'-')[1] eq fit.itemValue}">selected="selected"</c:if> value="${fit.itemCode}-${fit.itemValue}" >
                                    ${fit.itemName}
                            </option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="searchSm clearfix">
                <!-- 尺码组 -->
                <p class="searchTxt"><spring:message code="size_sizeGroup"/></p>
                <div class="searchInp">
                    <select style="width:100px" id="styleSizeGroupCd" name="sizegroupCd" onchange="subStyleSize(this,'styleSizeCd')" data-rule-required="true" data-msg-required="<spring:message code="fitproperty_pleaseChoosedUnit"/>" >
                        <option value=""><spring:message code="size_pleaseChoosed"/></option>
                        <c:forEach items="${fns:getDictList(sizeGroup)}"   var="group">
                            <option data-value="${group.itemValue}" <c:if test="${fn:split(consumption.sizegroupCd,'-')[1] eq group.itemValue}">selected="selected"</c:if> value="${group.itemCode}-${group.itemValue}" >
                                    ${group.itemName}
                            </option>
                        </c:forEach>
                    </select>
                </div>
                <div class="searchInp">
                    <select style="width:100px"  id="styleSizeCd" name="sizeCd" >
                        <option value=""><spring:message code="size_pleaseChoosed"/></option>
                        <c:forEach items="${fns:getDictList(fn:split('', '-')[1])}" var="styleSize">
                            <option
                                    value="${styleSize.itemCode}-${styleSize.itemValue}">
                                    ${styleSize.itemName}
                            </option>
                        </c:forEach>
                    </select>
                </div>
            </div>
        </div>
        <div class="searchRight">
            <%-- <!-- 新建 -->
            <button type="button" class="btn-cj" onclick="popup('935px','550px','${ctx}/fabric/consumption/form')"><spring:message code="common_create"/></button> --%>
            <!-- 重置 -->
            <button type="button" class="btn-js" onclick="clean();"><spring:message code="common_reset"/></button>
            <!-- 查询 -->
            <button type="button" class="btn-js" onclick="return page();"><spring:message code="commom_check"/></button>
        </div>
    </div>
</form>
<div class="tableBox">
    <div class="tableBoxScroll">
        <table cellpadding="0" class="tableCon">
            <thead>
            <tr>
                <!-- 序号No. -->
                <th><spring:message code="common_no"/></th>
                <!-- 款式类别 -->
                <th><spring:message code="size_styleCategory"/></th>
                <!-- 版型 -->
                <th><spring:message code="size_styleFit"/></th>
                <!-- 尺码组 -->
                <th><spring:message code="size_sizeGroup"/></th>
                <!-- 尺码 -->
                <th><spring:message code="size_size"/></th>
                <!-- 面料单耗 -->
                <th><spring:message code="size_sizeUnitCost"/></th>
                <!-- 状态 -->
                <th><spring:message code="size_state"/></th>
                <!-- 更新人 -->
                <th><spring:message code="size_update_user"/></th>
                <!-- 更新日期 -->
                <th><spring:message code="size_update"/></th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="consumption" varStatus="status">
                <tr>
                    <td>
                        <p>${(page.pageNo-1)*page.pageSize + status.index+1}</p>
                    </td>
                    <td>
                        <p data-toggle="tooltip" title="${fns:getDictName(consumption.styleCategoryCd)}">${fns:getDictName(consumption.styleCategoryCd)}</p>
                    </td>
                    <td>
                        <p data-toggle="tooltip" title="${fns:getDictName(consumption.fitCd)}">${fns:getDictName(consumption.fitCd)}</p>
                    </td>
                    <td>
                        <p data-toggle="tooltip" title="${fns:getDictName(consumption.sizegroupCd)}">${fns:getDictName(consumption.sizegroupCd)}</p>
                    </td>
                    <td>
                        <p data-toggle="tooltip" title="${fns:getDictName(consumption.sizeCd)}">${fns:getDictName(consumption.sizeCd)}</p>
                        <!-- onclick="popup('800px','470px','${ctx}/fabric/consumption/show?id=${consumption.id}')" -->
                    </td>
                    <td>
                        <p><fmt:formatNumber value="${consumption.sizeUnitCost}" pattern="#,##0.000#"/></p>
                    </td>
                    <td>
                        <c:choose>
                            <c:when test="${consumption.enableFlag eq 1}"><spring:message code="size_enable"/></c:when>
                            <c:when test="${consumption.enableFlag eq 0}"><spring:message code="size_disable"/></c:when>
                        </c:choose>
                    </td>
                    <td>
                        <p>${consumption.updateName}</p>
                    </td>
                    <td>
                        <p><fmt:formatDate value="${consumption.updateDate}" pattern="yyyy-MM-dd HH:mm" /></p>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <c:if test="${empty page.list}" >
            <div class="tableNone">
                <img src="${ctxStatic}/images/icon-03.png" height="20"> <spring:message code="There_is_no_data"/>
            </div>
        </c:if>
    </div>
    <%@ include file="/WEB-INF/views/include/page.jsp"%>
</div>
<script>
    window.onload = function() {
        tableH()
    }
    window.onresize = function() {
        tableH()
    }
</script>
</body>
</html>